thin.imports('/public/home/css/global.project.css');

thin.imports('/public/configure/conf.project.js');

thin.use(function() {

	// 路由
	checkLocation();
	
	$.showLoading();
	__getdata_prome['model'] = 0;
	factory.request('_project_me');
	
	// 绑定项目未评估按钮
	$('#prolist-w').on('click', 'a', function() {
		window.location.href = '/mobile/project/review';
	});
	// 绑定项目已评估按钮
	$('#prolist-y').on('click', 'a', function() {
		var index = $(this).attr('data-index'),
			proid = $(this).attr('data-proid');
		
		window.location.href = '/mobile/chain/fund?index=' + index + '&proid=' + proid;
	});
});

var __getdata_prome = {};

// 获取项目回调
function __complete_prome(res) {
	$.hideLoading();
	if(res.status == 200) {
		createProjectList(res.data);
	} else {
		$.toptip(res.error, 'error');
	}
}

function createProjectList(data) {
	var is_on = 0,
		is_off = 0;
	for(var i in data) {
		var list = data[i];
		var ele = '';
		ele += '<a href="javascript:;" class="weui-media-box weui-media-box_appmsg weui-cell_access bg-ffffff" data-index="' + i + '" data-proid="' + list.id + '">';
		ele += '<div class="weui-media-box__hd">';
		ele += '<img class="weui-media-box__thumb pro-logo" src="' + list.logo + '" alt="">';
		ele += '</div>';
		ele += '<div class="weui-media-box__bd">';
		ele += '<h4 class="weui-media-box__title">' + list.title + '</h4>';
		ele += '<p class="weui-media-box__desc">' + list.words + '</p>';
		ele += '</div>';
		ele += '<span class="weui-cell__ft p-l-2x">' + (list.is_cp == 0 ? '项目评估' : '一键融资') + '</span>';
		ele += '</a>';
		if (list.is_cp == 0) {
			// 未评估
			$('#prolist-w').find('#project-volist').append(ele);
			is_off++;
		} else {
			// 已评估
			$('#prolist-y').find('#project-volist').append(ele);
			is_on++;
		}
	}
	$('#prolist-w').show();
	$('#prolist-y').show();
	if (is_off > 0) {
		$('#prolist-w').find('.nothing-box').hide();
	}
	if (is_on > 0) {
		$('#prolist-y').find('.nothing-box').hide();
	}
}